import web
import pymongo

urls = (
        '/(.*)', 'initdata'
)
app = web.application(urls, globals())

class initdata:
        def GET(self, name):
            return 'iPhone2.0 Client UV:'+str(self.statictis())

        def statictis(self):
            connection = pymongo.Connection("10.103.13.42",27017)
            db = connection.initdata
            collection = db.posts
            posts = collection.find({"brand":"apple"}) 
            results = []
            for post in posts :
                results.append(post.get('guid', ''))
            
            phone2uv = set(results)
            
            print len(phone2uv)
            
            return len(phone2uv)

if __name__ == "__main__":
        app.run()
